<script type="text/javascript" xmlns:e="http://www.w3.org/1999/html">
    AppComm.include.load("#url('/static/js/user/menuManagement.js')", "js");
</script>
<div class="layui-tab-item layui-show">
    <div style="text-align: left;">
        <span class="layui-breadcrumb">
                <a href="">系统管理</a>
                <a><cite>菜单管理</cite></a>
        </span>
    </div>
    <hr>
    <div class="menuManagement_box"></div>
</div>

<script id="menuManagementList_template" type="text/html">
    <div style="text-align: left;">
        <form class="layui-form" lay-filter="searchForm" action="">
            <div class="layui-inline">
                &nbsp;&nbsp;
                <button class="layui-btn layui-btn-normal" id="addBtn">添加</button>
            </div>
        </form>
    </div>

    <div style="width:100%">
        <div id="tb_list" lay-filter="tb_list" style="width:100%"></div>
    </div>
</script>

<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="editBtn">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="deleteBtn">删除</a>
</script>

<script id="menuManagementForm_template" type="text/html">
    <div class="layui-tab-item layui-show" style="width:652px;margin: 0 auto;">
        <form class="layui-form" action="">
        <input type="hidden" id="id" value="{{menuBo.id}}" >
        <div class="layui-form-item">
                <label class="layui-form-label">标识</label>
                <div class="layui-input-inline">
                    <input type="text" id="menuKey" name="menuKey" required  lay-verify="menuKey" placeholder="请输入标识" autocomplete="off" class="layui-input" value="{{menuBo.menuKey}}">
                </div>
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="menuName" name="menuName" required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{menuBo.menuName}}">
                </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">级别</label>
                <div class="layui-input-inline">
                    <select id="level" name="level" lay-verify="required" lay-search="" lay-filter="level_edit">
                        {{if menuBo.level==2}}
                        <option value="1">1</option>
                        <option value="2" selected="selected">2</option>
                        {{/if}}
                        {{if menuBo.level!=2}}
                        <option value="1"  selected="selected">1</option>
                        <option value="2">2</option>
                        {{/if}}
                    </select>
                </div>
                <label class="layui-form-label">父级菜单</label>
                <div class="layui-input-inline" id="parentId_edit">
                    <select id="parentId" name="parentId" lay-verify="required" lay-search="">
                        {{if menuBo.level==1}}
                            <option value="0">主菜单</option>
                        {{/if}}
                        {{if menuBo.level==2}}
                            {{each parentList as pl i}}
                            {{if menuBo.parentId==pl.id}}
                            <option value="{{pl.id}}" selected="selected">{{pl.menuName}}</option>
                            {{/if}}
                            {{if menuBo.parentId!=pl.id}}
                            <option value="{{pl.id}}">{{pl.menuName}}</option>
                            {{/if}}
                            {{/each}}
                        {{/if}}
                    </select>
                </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">说明</label>
            <div class="layui-input-inline">
                <input style="width:502px;" type="text" id="comment" name="comment" placeholder="请输入说明内容" autocomplete="off" class="layui-input" value="{{menuBo&&menuBo.comment}}">
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">级别</label>
                <div class="layui-input-inline">
                    <select id="target" name="target" lay-verify="required" lay-search="">
                        {{each menuTarget as mt i}}
                        {{if menuBo.target==mt.key}}
                        <option value="{{mt.key}}" selected="selected">{{mt.name}}</option>
                        {{/if}}
                        {{if menuBo.target!=mt.key}}
                        <option value="{{mt.key}}">{{mt.name}}</option>
                        {{/if}}
                        {{/each}}
                    </select>
                </div>
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="text" id="orderId" name="orderId" lay-verify="number" placeholder="请输入排序号" autocomplete="off" class="layui-input" value="{{menuBo&&menuBo.orderId}}">
                </div>

        </div>
        <div class="layui-form-item" id="href_edit">
            <label class="layui-form-label">链接</label>
            <div class="layui-input-inline">
                <input style="width:502px;" type="text" id="href" name="href" placeholder="请输入链接" autocomplete="off" class="layui-input" value="{{menuBo&&menuBo.href}}">
            </div>
        </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <label style="color: red">菜单关键字：模块名_业务名，如user_management</label>
                    <br>
                    <br>
                    <label style="color: red">链接：如user/nav/management</label>
                </div>
            </div>
        <br>
        <div class="layui-form-item">
            <div class="layui-inline" style="margin-left: 225px;width:142px;">
                #hasPermission('menu:save','<button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit="" lay-filter="saveBtn">提交</button>')
                <button class="layui-btn layui-btn-normal" id="cancelBtn">取消</button>
            </div>
        </div>
        </form>
    </div>
</script>

<script id="menuManagementForm_template_add" type="text/html">
    <div class="layui-tab-item layui-show" style="width:652px;margin: 0 auto;">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">菜单关键字</label>
            <div class="layui-input-inline">
                <input type="text" id="menuKey_add" name="menuKey_add" lay-verify="menuKey_add" placeholder="请输入标识" autocomplete="off" class="layui-input" value="">
            </div>
            <label class="layui-form-label">名称</label>
            <div class="layui-input-inline">
                <input type="text" id="menuName_add" name="menuName_add" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">级别</label>
            <div class="layui-input-inline">
                <select id="level_add" name="level_add" lay-verify="required" lay-search="" lay-filter="level">
                    <option value="1"  selected="selected">1</option>
                    <option value="2">2</option>
                </select>
            </div>
            <label class="layui-form-label">父级菜单</label>
            <div class="layui-input-inline" id="parentId_div" lay-filter="parentId">
                <select id="parentId_add" name="parentId_add" lay-verify="required" lay-search="" lay-filter="parentId">
                    <option value="0">主菜单</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">说明</label>
            <div class="layui-input-inline">
                <input style="width:502px;" type="text" id="comment_add" name="comment_add" placeholder="请输入说明内容" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">打开方式</label>
            <div class="layui-input-inline">
                <select id="target_add" name="target_add"  lay-search="">
                    {{each menuTarget as mt i}}
                    <option value="{{mt.key}}" selected="selected">{{mt.name}}</option>
                    {{/each}}
                </select>
            </div>
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" id="orderId_add" name="orderId_add" lay-verify="number" placeholder="请输入排序号" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item" id="href_div">
            <label class="layui-form-label">链接</label>
            <div class="layui-input-inline">
                <input style="width:502px;" type="text" id="href_add" name="href_add" placeholder="请输入链接" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <label style="color: red">菜单关键字：模块名_业务名，如user_management</label>
                <br>
                <br>
                <label style="color: red">链接：如user/nav/management</label>
            </div>
        </div>
    <br>

    <div class="layui-form-item">
        <div class="layui-inline" style="margin-left: 225px;width:182px;">
            <button class="layui-btn layui-btn-normal" lay-submit="" id="saveBtn_add" lay-filter="saveBtn_add">提交</button>
            <button class="layui-btn layui-btn-normal" id="cancelBtn_add">取消</button>
        </div>
    </div>
    </form>
    </div>
</script>

<script id="menuManagementForm_permission" type="text/html">
    <form class="layui-form" action="" url="permission">
        <div class="layui-form-item">
            <label class="layui-form-label">分配角色</label>
            <div class="layui-input-block">
                {{each data as object i }}
                <input type="checkbox" name="role[{{index}}]" title="{{object.roleName}}" value="{{object.id}}" id="{{object.id}}" lay-filter="{{object.id}}">
                {{/each}}
            </div>
        </div>
    </form>
    <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtnPer" id="saveBtnPer">提交</button>
        <button class="layui-btn layui-btn-normal" id="cancelBtnPer">取消</button>
    </div>
</script>